﻿using EmitDebugging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Reflection.Emit;

namespace EmitDebugging.Tests
{
	[TestClass]
	public sealed class AssemblyDebuggingTests : AssemblyCreationTests
	{
		[TestMethod, ExpectedException(typeof(ArgumentNullException))]
		public void CreateWithNullArgument()
		{
			new AssemblyDebugging(null, null, null);
		}

		[TestMethod]
		public void CallDisposeAfterDisposing()
		{
			AssemblyDebugging assembly = null;
			
			using(assembly = AssemblyCreationTests.CreateDebuggingAssembly("Me"))
			{			
			}
			
			assembly.Dispose();
		}

		[TestMethod, ExpectedException(typeof(ObjectDisposedException))]
		public void CallEqualsAfterDisposing()
		{
			AssemblyDebugging assembly = null;

			using(assembly = AssemblyCreationTests.CreateDebuggingAssembly("Me"))
			{
			}

			assembly.GetTypeDebugging(null);
		}
	}
}
